const {Model, DataTypes} = require('sequelize');
const sequelize = require('../config/db');

class RelatedEvents extends Model {}
//历史事件模型
RelatedEvents.init({
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    name: {
        type: DataTypes.STRING, 
        allowNull: false,
        comment: '历史事件名称'
    },
    description: {
        type: DataTypes.TEXT,
        allowNull: true,
        comment: '历史事件描述' 
        
    },
    goods_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        comment: '商品id',
        references: {
            model: 'goods',
            key: 'id'
        }
    },
    date: {
        type: DataTypes.STRING,
        allowNull: true,
        comment: '历史事件日期'
    }
}, {    
    sequelize,
    modelName: 'related_events',
    tableName: 'related_events',
    timestamps: false

});

module.exports = RelatedEvents;
